
// 应用mvc 框架
const express = require('express'),
      path = require('path'),
      opn = require('opn'),

      // 表单提交模块
    bodyParser = require('body-parser'),
    // 引入session模块
    session = require('express-session'),
    // 引入cookie模块
    cookieParser = require('cookie-parser');

//创建应用
const app = express();

//设置静态资源目录

 app.use(express.static(path.join(__dirname,"/assets")));

const mutipart= require('connect-multiparty');

const mutipartMiddeware = mutipart();

 app.use(mutipart({ uploadDir:path.join(__dirname,"/assets/static/uploads") }));



//使用session中间件
app.use(session({secret:'H1801',cookie:{maxAge:null},rolling:true,resave:false,saveUninitialized:true}));

//设置body-parser 中间层获取post数据  
app.use(bodyParser.urlencoded({extended:false}));

//将cookie挂载到应用当中去
app.use(cookieParser());

//引入路由 并启动
var Router = require("./src/routers/index");

//给应用设置路由
Router(app);
//设置端口
app.listen(4000,function(){
  console.log('服务已开启');
  


});